home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2437 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1006 b 

  1. Path: is.bbsrc.ac.uk!news
  2. From: Robert Tuck <Robert.Tuck@bbsrc.ac.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Recursive Definition?
  5. Date: 17 Jan 1996 13:11:04 GMT
  6. Organization: BBSRC
  7. Message-ID: <4dish8$43c@is.bbsrc.ac.uk>
  8. References: <4df39j$f80@news.vcd.hp.com>
  9. NNTP-Posting-Host: pc0075.co.bbsrc.ac.uk
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  14.  
  15. [...]
  16. >      static const Switch On;
  17. >      static const Switch Off;
  18. [...]
  19. >const Switch Switch::On = 1;
  20. >const Switch Switch::Off = 0;
  21. >
  22. >What are the above two statements trying to initialize?
  23. >It seems to me that they are sort of doing a recursive
  24. >initialization.  Please help!!!!
  25.  
  26. It looks to me like On and Off should be ints, not Switchs. The 
  27. respective lines should read:
  28.  
  29.       static const int On;
  30.       static const int Off;
  31.  
  32. and
  33.  
  34. const int Switch::On = 1;
  35. const int Switch::Off = 0;
  36.  
  37. A member of a class cannot be an object of that same class.
  38.  
  39. Rob.
  40.  
  41.  
  42.